package com.zc.study.designPattern.行为型设计模式.MediatorPattern;



public class ConcreteMediator extends Mediator{
    //维持对各个同时对象的引用
    public Button addButton;
    public List list;

    public TextBox userNameTextBox;
    public ComboBox cb;

    //封装同事对象之间的交互
    @Override
    public void componentChanged(Component c) {
        //单击按钮
        if(c == addButton){
            System.out.println("--单击增加按钮--");
            list.update();
            cb.update();
            userNameTextBox.setText();
        }
        //从列表框中选中客户
        else if(c == list){
            System.out.println("--从列表框中选择客户--");
            cb.select();
            userNameTextBox.setText();
        }
        //从组合框中选择客户
        else if(c == cb){
            System.out.println("--从组合框选择客户--");
            cb.select();
            userNameTextBox.setText();
        }
    }
}
